import { defineConfig,loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { viteCommonjs } from '@originjs/vite-plugin-commonjs'
import path from 'path'

export default ({command,mode})=>{

  return defineConfig({
    server: {
      host: true,
      open: true,
      port: 9000
    },
    plugins: [
      vue(),
      AutoImport ({
        imports: ["vue","vue-router","pinia",
        ], //自动引入vue的ref、toRefs、onmounted等，无需在页面中再次引入
        dts: 'src/auto-import.d.ts',
      }),
      Components({
        resolvers: [ElementPlusResolver()],
      }),
      viteCommonjs(),
    ],
    optimizeDeps: {
      include: ['jquery']
    },
    resolve: {
      alias: {
        '@': path.resolve(__dirname, './src')
      },
      resolvers: [ElementPlusResolver()]
    },
    define: {
    }
  })
}

